//
//  PMineResumeIntentionInfoModel.m
//  Btpin
//
//  Created by Vic on 2019/3/24.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "PMineResumeIntentionInfoModel.h"

@implementation PMineResumeIntentionInfoModel

- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues {
    self.jobs_id = [UIToolsControl dataAnalysis:keyedValues[@"jobs_id"]];
    self.jobs = [UIToolsControl dataAnalysis:keyedValues[@"jobs"]];
    self.wage = [UIToolsControl dataAnalysis:keyedValues[@"wage"]];
    self.wage_cn = [UIToolsControl dataAnalysis:keyedValues[@"wage_cn"]];
    self.nature = [UIToolsControl dataAnalysis:keyedValues[@"nature"]];
    self.nature_cn = [UIToolsControl dataAnalysis:keyedValues[@"nature_cn"]];
    
    self.district = @"";
    self.district_cn = @"";
    self.districtArr = [NSMutableArray arrayWithCapacity:0];
    if (keyedValues[@"district"] && [keyedValues[@"district"] isKindOfClass:[NSArray class]]) {
        for (NSDictionary *dic in keyedValues[@"district"]) {
            PublicCategoryElementModel *model = [[PublicCategoryElementModel alloc] init];
            model.id = [UIToolsControl dataAnalysis:dic[@"idstr"]];
            model.name = [UIToolsControl dataAnalysis:dic[@"name"]];
            [self.districtArr addObject:model];
            
            self.district = [NSString stringWithFormat:@"%@,%@", model.id, self.district];
            self.district_cn = [NSString stringWithFormat:@"%@ %@", model.name, self.district_cn];
        }
        if (self.district && self.district.length>2) {
            self.district = [self.district substringToIndex:self.district.length-1];
            NSArray *arr = [self.district componentsSeparatedByString:@"."];
            if (arr && arr.count && ![arr[1] isEqualToString:@"0"]) {
                self.district = arr[1];
            } else {
                self.district = arr[0];
            }
        }
    } else {
        self.district = [UIToolsControl dataAnalysis:keyedValues[@"district"]];
        self.district_cn = [UIToolsControl dataAnalysis:keyedValues[@"district_cn"]];
    }
    self.trade = @"";
    self.trade_cn = @"";
    self.tradeArr = [NSMutableArray arrayWithCapacity:0];
    if (keyedValues[@"trade"] && [keyedValues[@"trade"] isKindOfClass:[NSArray class]]) {
        for (NSDictionary *dic in keyedValues[@"trade"]) {
            PublicCategoryElementModel *model = [[PublicCategoryElementModel alloc] init];
            model.id = [UIToolsControl dataAnalysis:dic[@"idstr"]];
            model.name = [UIToolsControl dataAnalysis:dic[@"name"]];
            [self.tradeArr addObject:model];
            self.trade = [NSString stringWithFormat:@"%@,%@", model.id, self.trade];
            self.trade_cn = [NSString stringWithFormat:@"%@ %@", model.name, self.trade_cn];
        }
        if (self.trade && self.trade.length>2) {
            self.trade = [self.trade substringToIndex:self.trade.length-1];
        }
    } else {
        self.trade = [UIToolsControl dataAnalysis:keyedValues[@"trade"]];
        self.trade_cn = [UIToolsControl dataAnalysis:keyedValues[@"trade_cn"]];
        if (self.trade_cn && self.trade_cn.length) {
            
        } else {
            self.trade_cn = @"行业不限";
        }
    }
    
    self.catgory_id = @"";
    self.catgory_cn = @"";
    self.catgory = [NSMutableArray arrayWithCapacity:0];
    if (keyedValues[@"catgory"] && [keyedValues[@"catgory"] isKindOfClass:[NSArray class]]) {
        for (NSDictionary *dic in keyedValues[@"catgory"]) {
            PublicCategoryElementModel *model = [[PublicCategoryElementModel alloc] init];
            model.id = [UIToolsControl dataAnalysis:dic[@"idstr"]];
            model.name = [UIToolsControl dataAnalysis:dic[@"name"]];
            [self.catgory addObject:model];
            self.catgory_id = [NSString stringWithFormat:@"%@,%@", model.id, self.catgory_id];
            self.catgory_cn = [NSString stringWithFormat:@"%@ %@", model.name, self.catgory_cn];
        }
        if (self.catgory_id && self.catgory_id.length>2) {
            self.catgory_id = [self.catgory_id substringToIndex:self.catgory_id.length-1];
            NSArray *arr = [self.catgory_id componentsSeparatedByString:@"."];
            self.catgory_id = arr.lastObject;
        }
    }
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

- (id)copyWithZone:(NSZone *)zone {
    PMineResumeIntentionInfoModel *model = [[[self class] allocWithZone:zone] init];
    model.jobs_id = self.jobs_id;
    model.jobs = self.jobs;
    model.wage = self.wage;
    model.wage_cn = self.wage_cn;
    model.district = self.district;
    model.district_cn = self.district_cn;
    model.trade = self.trade;
    model.trade_cn = self.trade_cn;
    model.nature = self.nature;
    model.nature_cn = self.nature_cn;
    
    model.catgory = [NSMutableArray arrayWithCapacity:0];
    if (self.catgory && self.catgory.count) {
        for (PublicCategoryElementModel *tempModel in self.catgory) {
            PublicCategoryElementModel *model1 = [[PublicCategoryElementModel alloc] init];
            model1 = [tempModel copy];
            [model.catgory addObject:model1];
        }
    }
    
    model.districtArr = [NSMutableArray arrayWithCapacity:0];
    if (self.districtArr && self.districtArr.count) {
        for (PublicCategoryElementModel *tempModel in self.districtArr) {
            PublicCategoryElementModel *model1 = [[PublicCategoryElementModel alloc] init];
            model1 = [tempModel copy];
            [model.districtArr addObject:model1];
        }
    }
    
    model.tradeArr = [NSMutableArray arrayWithCapacity:0];
    if (self.tradeArr && self.tradeArr.count) {
        for (PublicCategoryElementModel *tempModel in self.tradeArr) {
            PublicCategoryElementModel *model1 = [[PublicCategoryElementModel alloc] init];
            model1 = [tempModel copy];
            [model.tradeArr addObject:model1];
        }
    }
    
    return model;
}

@end
